package com.irdstudio.cdp.pboc.service.impl;

import java.util.List;
import java.util.Objects;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.irdstudio.cdp.pboc.service.dao.PbocDeliverySumDao;
import com.irdstudio.cdp.pboc.service.domain.PbocDeliverySum;
import com.irdstudio.cdp.pboc.service.facade.PbocDeliverySumService;
import com.irdstudio.cdp.pboc.service.vo.PbocDeliverySumVO;
import com.irdstudio.basic.framework.core.base.FrameworkService;
/**
 * <p>ServiceImpl: 逾期（透支）信息汇总  				<p>
 * @author ligm
 * @date 2018-12-27
 */
@Service("pbocDeliverySumService")
public class PbocDeliverySumServiceImpl implements PbocDeliverySumService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(PbocDeliverySumServiceImpl.class);

	@Autowired
	private PbocDeliverySumDao pbocDeliverySumDao;
	
	/**
	 * 新增操作
	 */
	public int insertPbocDeliverySum(PbocDeliverySumVO inPbocDeliverySumVo)  throws Exception {
		logger.debug("当前新增数据为:"+ inPbocDeliverySumVo.toString());
		int num = 0;
		try {
			PbocDeliverySum pbocDeliverySum = new PbocDeliverySum();
			beanCopy(inPbocDeliverySumVo, pbocDeliverySum);
			num = pbocDeliverySumDao.insertPbocDeliverySum(pbocDeliverySum);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
			throw e;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

	/**
	 * 删除操作
	 */
	public int deleteByPk(PbocDeliverySumVO inPbocDeliverySumVo)  throws Exception {
		logger.debug("当前删除数据条件为:"+ inPbocDeliverySumVo);
		int num = 0;
		try {
			PbocDeliverySum pbocDeliverySum = new PbocDeliverySum();
			beanCopy(inPbocDeliverySumVo, pbocDeliverySum);
			num = pbocDeliverySumDao.deleteByPk(pbocDeliverySum);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
			throw e;
		}
		logger.debug("根据条件:"+ inPbocDeliverySumVo +"删除的数据条数为"+ num);
		return num;
	}


	/**
	 * 更新操作
	 */
	public int updateByPk(PbocDeliverySumVO inPbocDeliverySumVo)  throws Exception {
		logger.debug("当前修改数据为:"+ inPbocDeliverySumVo.toString());
		int num = 0;
		try {
			PbocDeliverySum pbocDeliverySum = new PbocDeliverySum();
			beanCopy(inPbocDeliverySumVo, pbocDeliverySum);
			num = pbocDeliverySumDao.updateByPk(pbocDeliverySum);
		} catch (Exception e) {
			logger.error("修改数据发生异常!", e);
			num = -1;
			throw e;
		}
		logger.debug("根据条件:"+ inPbocDeliverySumVo +"修改的数据条数为"+ num);
		return num;
	}
	
	/**
	 * 查询操作
	 */
	public PbocDeliverySumVO queryByPk(PbocDeliverySumVO inPbocDeliverySumVo) {
		
		logger.debug("当前查询参数信息为:"+ inPbocDeliverySumVo);
		try {
			PbocDeliverySum queryPbocDeliverySum = new PbocDeliverySum();
			beanCopy(inPbocDeliverySumVo, queryPbocDeliverySum);
			PbocDeliverySum queryRslPbocDeliverySum = pbocDeliverySumDao.queryByPk(queryPbocDeliverySum);
			if (Objects.nonNull(queryRslPbocDeliverySum)) {
				PbocDeliverySumVO outPbocDeliverySumVo = beanCopy(queryRslPbocDeliverySum, new PbocDeliverySumVO());
				logger.debug("当前查询结果为:"+ outPbocDeliverySumVo.toString());
				return outPbocDeliverySumVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
			throw e;
		}
		return null;
	}


	/**
	 * 查询用户权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<PbocDeliverySumVO> queryAllOwner(PbocDeliverySumVO pbocDeliverySumVo)  throws Exception {

		logger.debug("当前查询本人所属数据信息的参数信息为:");
		List<PbocDeliverySumVO> list = null;
		try {
			List<PbocDeliverySum> pbocDeliverySums = pbocDeliverySumDao.queryAllOwnerByPage(pbocDeliverySumVo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:"+ pbocDeliverySums.size());
			pageSet(pbocDeliverySums, pbocDeliverySumVo);
			list = (List<PbocDeliverySumVO>) beansCopy(pbocDeliverySums, PbocDeliverySumVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
			throw e;
		}
		
		return list;
	
	}


	/**
	 * 查询当前机构权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<PbocDeliverySumVO> queryAllCurrOrg(PbocDeliverySumVO pbocDeliverySumVo)  throws Exception {

		logger.debug("当前查询本人所属机构数据信息的参数信息为:");
		List<PbocDeliverySum> pbocDeliverySums = pbocDeliverySumDao.queryAllCurrOrgByPage(pbocDeliverySumVo);
		logger.debug("当前查询本人所属机构数据信息的结果集数量为:"+pbocDeliverySums.size());
		List<PbocDeliverySumVO> list = null;
		try {
			pageSet(pbocDeliverySums, pbocDeliverySumVo);
			list = (List<PbocDeliverySumVO>) beansCopy(pbocDeliverySums, PbocDeliverySumVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
			throw e;
		}
		
		return list;
	
	}


	/**
	 * 查询当前机构及下属机构权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<PbocDeliverySumVO> queryAllCurrDownOrg(PbocDeliverySumVO pbocDeliverySumVo)  throws Exception {

		logger.debug("当前查询本人所属机构及以下数据信息的参数信息为:");
		List<PbocDeliverySum> pbocDeliverySums = pbocDeliverySumDao.queryAllCurrDownOrgByPage(pbocDeliverySumVo);
		logger.debug("当前查询本人所属机构及以下数据信息的结果集数量为:"+ pbocDeliverySums.size());
		List<PbocDeliverySumVO> list = null;
		try {
			pageSet(pbocDeliverySums, pbocDeliverySumVo);
			list = (List<PbocDeliverySumVO>) beansCopy(pbocDeliverySums, PbocDeliverySumVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
			throw e;
		}
		
		return list;
	
	}
	/**
	 * 需求编号:2019D0519
	 * 问题编号:
	 * 开发人员: caoxin
	 * 创建日期:2019/7/19
	 * 功能描述:查询逾期(逾期信息汇总):
	 * 修改日期:2019/7/19
	 * 修改描述:
	 */
//	@author:liuty
//	@date:2019/10/17
//	涉及产品:税e贷
//	功能:查询逾期(逾期信息汇总):
//	原因:增量投产只投了接口没投实现，编译报错因此注释，不影响实际业务
//	@Override
//	public List<PbocDeliverySumVO> selectByReportId(PbocDeliverySumVO pbocDeliverySumVo) {
//		logger.debug("当前查询参数信息为:"+ pbocDeliverySumVo);
//		List<PbocDeliverySumVO> list = null;
//		try {
//			List<PbocDeliverySum> pbocCreditStatus = pbocDeliverySumDao.selectByReportId(pbocDeliverySumVo);
//			list = (List<PbocDeliverySumVO>) beansCopy(pbocCreditStatus, PbocDeliverySumVO.class);
//		} catch (Exception e) {
//			logger.error("查询数据发生异常!", e);
//		}
//		return list;
//	}
}
